package com.juyu.reader.pc.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.juyu.reader.pc.model.User;

public class AllInterceptor implements HandlerInterceptor {
	Logger logger = Logger.getLogger(AllInterceptor.class);

	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
		// TODO Auto-generated method stub

		String lastUrl = request.getRequestURL().toString() + "?" + request.getQueryString();

		//logger.info("lastUrl=" + lastUrl);
		request.getSession().setAttribute(Constants.LAST_URL, lastUrl);
		return true;
	}
}
